home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1CRF909 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.8 KB  |  40 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import com.sun.java.swing.JToolBar;
  4. import com.sun.java.swing.border.AbstractBorder;
  5. import java.awt.Component;
  6. import java.awt.Graphics;
  7. import java.awt.Insets;
  8.  
  9. public class MetalToolBarBorder extends AbstractBorder {
  10.    protected MetalBumps bumps = new MetalBumps(10, 10, MetalLookAndFeel.getControlHighlight(), MetalLookAndFeel.getControlDarkShadow(), MetalLookAndFeel.getMenuBackground());
  11.  
  12.    public Insets getBorderInsets(Component c) {
  13.       Insets borderInsets = new Insets(2, 2, 2, 2);
  14.       if (((JToolBar)c).isFloatable()) {
  15.          if (c.getSize().height <= c.getSize().width) {
  16.             borderInsets.left = 16;
  17.          } else {
  18.             borderInsets.top = 16;
  19.          }
  20.       }
  21.  
  22.       return borderInsets;
  23.    }
  24.  
  25.    public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
  26.       g.translate(x, y);
  27.       if (((JToolBar)c).isFloatable()) {
  28.          if (c.getSize().height <= c.getSize().width) {
  29.             this.bumps.setBumpArea(10, c.getSize().height - 4);
  30.             this.bumps.paintIcon(c, g, 2, 2);
  31.          } else {
  32.             this.bumps.setBumpArea(c.getSize().width - 4, 10);
  33.             this.bumps.paintIcon(c, g, 2, 2);
  34.          }
  35.       }
  36.  
  37.       g.translate(-x, -y);
  38.    }
  39. }
  40.